package org.gd.httprequests;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Gorhover
 */
public class PatternCallable implements Callable<List<String>> {

    private String content;
    private Pattern pattern;

    public PatternCallable(String content, Pattern pattern) {
        this.content = content;
        this.pattern = pattern;
    }

    @Override
    public List<String> call() throws Exception {
        List<String> list = new ArrayList<String>();
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            list.add(matcher.group());
        }
        return list;
    }
}
